"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BuildCommand = void 0;
const abstract_command_1 = require("./abstract.command");
class BuildCommand extends abstract_command_1.AbstractCommand {
    load(program) {
        program
            .command('build [packages]')
            .option('--build-dll', '只编译dll')
            .option('--build-dll-dev', '以 dev 模式编译dll')
            .option('--only-build-micro', '只编译子模块')
            .option('--concurrent-build-number [concurrentBuildNumber]', '并发编译子模块数量')
            .option('--non-interactive', 'do not show interactive prompts')
            .option('--only-build-parent', '只编译主模块')
            // .option('--packages [packages]', '指定编译那些子模块,逗号分隔多个模块')
            .option('--all-packages', '指定所有子模块')
            // .option('--build-micro-without-parent', '忽略父模块且只编译子模块')
            .option('--disable-build-dll', '禁止使用 dll')
            .option('--force-prod-dll', '强制使用 Prod Dll')
            .option('--force-enable-polyfill', '强制启用 polyfill')
            .option('--build-public-ms', '编译外部模块')
            .option('--build-dist-path [buildDistPath]', '只编译子模块')
            .option('--build-skip-parent', '跳过父模块编译')
            .option('--skip-unchanged-module', '跳过未变更的子模块编译')
            // .option('--skip-ts-check-in-start', 'yarn start 时, 是否跳过 ts 语法检查')
            // .option('--skip-eslint-check-in-start', 'yarn start 时, 是否跳过 eslint 语法检查。')
            .description('Build Cpaas application,[packages] 指定编译那些子模块,逗号分隔多个模块')
            .action((packages, command) => __awaiter(this, void 0, void 0, function* () {
            if (command.disableBuildDll) {
                process.env.DISABLE_BUILD_DLL = 'true';
            }
            if (command.forceProdDll) {
                process.env.FORCE_PROD_DLL = 'true';
            }
            if (command.forceEnablePolyfill) {
                process.env.FORCE_ENABLE_POLYFILL = 'true';
            }
            if (command.buildPublicMs) {
                process.env.BUILD_PUBLIC_MS = 'true';
            }
            if (command.buildDistPath) {
                process.env.BUILD_DIST_PATH = command.buildDistPath;
            }
            if (command.buildSkipParent) {
                process.env.BUILD_SKIP_PARENT = 'true';
            }
            if (command.skipUnchangedModule) {
                process.env.SKIP_NO_CHANGE_MODULE = 'true';
            }
            // if(command.skipTsCheckInStart) {
            //   process.env.SKIP_TS_CHECK_IN_START = 'true';
            // }
            // if(command.skipEslintCheckInStart) {
            //   process.env.SKIP_ESLINT_CHECK_IN_START = 'true';
            // }
            const options = [];
            options.push({ name: 'buildDll', value: !!command.buildDll });
            options.push({ name: 'buildDllDev', value: !!command.buildDllDev });
            options.push({
                name: 'onlyBuildMicro',
                value: !!command.onlyBuildMicro,
            });
            options.push({
                name: 'onlyBuildParent',
                value: !!command.onlyBuildParent,
            });
            options.push({
                name: 'concurrentBuildNumber',
                value: command.concurrentBuildNumber,
            });
            options.push({ name: 'allPackages', value: !!command.allPackages });
            options.push({
                name: 'nonInteractive',
                value: !!command.nonInteractive,
            });
            // options.push({
            //   name: 'buildMicroWithoutParent',
            //   value: !!command.buildMicroWithoutParent,
            // });
            options.push({
                name: 'path',
                value: command.path,
            });
            options.push({
                name: 'packages',
                value: packages,
            });
            const inputs = [];
            // inputs.push({ name: 'app', value: app });
            yield this.action.handle(inputs, options);
        }));
    }
}
exports.BuildCommand = BuildCommand;
